'''
Pdf file format stream data stuff
'''
import os
import re

class pdfParser:
	def __init__(self, filename):
		self.filename = filename
		self.content = open(self.filename,'r').read()
		if not self.isPDF(self.content):
			return
		#stream (0d 73 74 72 65 61 6d  0d 0a)
		#endstream (65 6e 64 73 74 72 65 61  6d)
		mat = re.findall('stream(.*)endstream', self.content, re.DOTALL)
		if mat != []:
			print mat
		
	def isPDF(self,content):
		firstLine = content[:content.find('\n')]
		if re.findall('%PDF-\d\.\d' ,firstLine, re.DOTALL):
			return True
		else:
			return False
		
pdfParser('test.pdf')
